//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics.Contracts;
using System.Windows.Media;
using OpenLS.Drawing;
using OpenLS.Drawing.UI;
using OpenLS.Drawing.UI.Internals;

namespace OpenLS.Chart.UI
{
    static class ElementFillToBrushConverter
    {
        public static Brush Convert(FillProperties props, ColorScheme colorScheme, ChartStyle chartStyle, ChartElementType type)
        {
            Contract.Requires(colorScheme != null);
            if (props == null)
            {
                if (colorScheme == null)
                {
                    return Brushes.Pink;
                }
                ColorBase cb = GetBrushFromElementType(chartStyle, type);

                return ColorBaseToBrushConverter.ColorBaseToBrush(cb, colorScheme);
            }
            return FillPropertiesToBrushConverter.FillPropertiesToBrush(props, colorScheme, null);
        }
        static ColorBase GetBrushFromElementType (ChartStyle chartStyle, ChartElementType type)
        {
            switch (type)
            {
                case ChartElementType.Background:
                    return chartStyle.ChartAreaFillColor;
                case ChartElementType.Floor:
                    return chartStyle.FloorColor;
                default:
                    throw new NotSupportedException();
            }
        }
    }
    enum ChartElementType
    {
        Floor,
        Background
    }
}
